import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';
import 'package:wk_robot2/app/widget/CommonWidgets.dart';

import '../../../event/DataCallBack.dart';
import '../../../routes/app_pages.dart';
import '../../../style/app_colors.dart';
import '../controllers/robots_detail_controller.dart';

class RobotsDetailView extends GetView<RobotsDetailController> {
  const RobotsDetailView({super.key});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColors.device_page_bg_color,
      appBar: AppBar(
        title: const Text('机器人详情'),
          leading: IconButton(
            icon: Image.asset('assets/images/ic_back2.png',width: 48.w,height: 48.h),
            onPressed: () {
              Get.back();
            },
            tooltip: MaterialLocalizations.of(context).backButtonTooltip, // 可选：设置工具提示
          ),
        centerTitle: true,
        bottom: controller.robotWhetherOnline.value ? PreferredSize(preferredSize: Size.fromHeight(0.h),child: SizedBox()): PreferredSize(
          preferredSize: Size.fromHeight(72.h),
          child: Container(
            padding: EdgeInsets.only(top: 18.h, bottom: 13.h,left: 40.w),
            color: AppColors.warning_tip_bgColor,
            width: MediaQuery.of(context).size.width,
            child: Text('机器人已经离线,无法实时同步机器人详情.',style: TextStyle(fontSize: 26.sp,color: Colors.red),),
          ),
        )

      ),
      body: ListView(
        children: [
          SizedBox(height: 60.h),
          Container(
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Image.asset('assets/images/ic_robot_detail.webp',width: 300.w,height: 322.h),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.all(40.h),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(16)),
              color: Colors.white
            ),
            child: Column(
              children: [
                Container(
                  padding: EdgeInsets.only(top: 22.h, bottom: 22.h,left: 30.w,right: 30.w),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text('固件升级',style: TextStyle(fontSize: 32.sp),),
                      Image.asset('assets/images/ic_arrow.webp',width: 30.w, height: 30.h),
                    ],
                  ),
                ),
                Container(
                  padding: EdgeInsets.only(left: 30.w,right: 30.w),
                  child:  CommonWidgets.getMyDivider(),
                ),
                Container(
                  padding: EdgeInsets.only(top: 22.h, bottom: 22.h,left: 30.w,right: 30.w),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text('恢复出厂设置',style: TextStyle(fontSize: 32.sp)),
                      Image.asset('assets/images/ic_arrow.webp',width: 30.w, height: 30.h),
                    ],
                  ),
                ),
                Container(
                  padding: EdgeInsets.only(left: 30.w,right: 30.w),
                  child:  CommonWidgets.getMyDivider(),
                ),
                GestureDetector(
                  onTap: () {
                    Get.toNamed(Routes.ABOUT_ROBOT,parameters: {
                      'robotUserId': controller.robotUserId.value
                    });
                  },
                  child: Container(
                    padding: EdgeInsets.only(top: 22.h, bottom: 22.h,left: 30.w,right: 30.w),
                    color: Colors.white.withOpacity(0),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('关于机器人',style: TextStyle(fontSize: 32.sp)),
                        Image.asset('assets/images/ic_arrow.webp',width: 30.w, height: 30.h),
                      ],
                    ),
                  ),
                ),
                
              ],
            ),
          ),
          GestureDetector(
            onTap: () {
              CommonWidgets.showConfirmDialog(Get.context!,'提示',"确定要解绑该机器人吗?","确定","取消",
                  DataCallBack(
                      confirmCallBack: (v) {
                        controller.unbind();
                      },
                      cancleCallBack: (v) {
                        print('no ....');
                      }
                  )
              );
            },
            child: Container(
              margin: EdgeInsets.all(40.h),
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(16)),
                  color: Colors.white
              ),
              child: Column(
                children: [
                  Container(
                    padding: EdgeInsets.only(top: 22.h, bottom: 22.h),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Text('解绑',style: TextStyle(fontSize: 32.sp,color: AppColors.btn_character_unbind_color))
                      ],
                    ),
                  ),


                ],
              ),
            ),
          )
        ],
      ),
    );
  }
}
